package com.wfg.blog.Mapper;

import com.wfg.blog.dao.dos.Archives;
import com.wfg.blog.dao.mapper.ArticleBodyMapper;
import com.wfg.blog.dao.mapper.ArticleMapper;
import com.wfg.blog.dao.mapper.TagMapper;
import com.wfg.blog.dao.mapper.UserMapper;
import com.wfg.blog.dao.pojo.ArticleBody;
import com.wfg.blog.dao.pojo.Tag;
import com.wfg.blog.dao.pojo.User;
import com.wfg.blog.service.TagService;
import com.wfg.blog.vo.TagVo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest
public class Mapper {
    @Autowired
    private TagService tagService;

    @Autowired
    private ArticleMapper articleMapper;

    @Autowired
    private TagMapper tagMapper;
    @Autowired
    private ArticleBodyMapper articleBodyMapper;
    @Autowired
    private UserMapper userMapper;


    @Test
    public void findTagsByArticleIdTest(){

        List<Tag> list = tagMapper.findTagsByArticleId(1l);
        System.out.println(list);
    }

    @Test
    public void name(){
        User user = userMapper.selectById(1);
        System.out.println(user.getName());
    }

    @Test
    public void findHostTags(){
        List<Long> hostTags = tagMapper.findHostTags(2);
        System.out.println(hostTags);

    }

    @Test
    public void findTagsByTagIds(){
        List<Long> tagIds = new ArrayList<>();
        tagIds.add(5l);
        List<Tag> tagsByTagIds = tagMapper.findTagsByTagIds(tagIds);
        System.out.println(tagsByTagIds);



    }
    //查询文章归档
    @Test
    public void listArchives(){
        List<Archives> archivesList = articleMapper.listArchives();
        System.out.println(archivesList);
    }

    //测试乱码
    @Test
    public void bodyMapper(){
        ArticleBody articleBody =new ArticleBody();
        articleBody.setArticleId(1l);
        articleBody.setContent("我是测试啊实打实的啊实打实的");
        articleBodyMapper.insert(articleBody);
    }
}
